﻿namespace Atlantis.Net.Irc
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    public class Channel
    {

        #region Constructor(s)

        public Channel(string channelName, IrcClient ircClient)
        {
            Name = channelName;
            m_Users = new Dictionary<string, char>(100);
            m_Client = ircClient;
            Modes = new List<char>(75);
        }

        #endregion

        #region Fields

        private IrcClient m_Client;

        #endregion

        #region Properties

        private List<char> m_Modes = null;
        /// <summary>
        ///     Gets or sets the channel modes set on the current channel
        /// </summary>
        public List<char> Modes
        {
            get { return m_Modes; }
            private set { m_Modes = value; }
        }

        private string m_Name = String.Empty;
        /// <summary>
        ///     Gets the channel name of the current channel
        /// </summary>
        public string Name
        {
            get { return m_Name; }
            private set { m_Name = value; }
        }

        private Dictionary<string, char> m_Users;
        /// <summary>
        ///     Gets a list of users and their access levels on the current channel
        /// </summary>
        public Dictionary<string, char> Users
        {
            get { return m_Users; }
            private set { m_Users = value; }
        }

        #endregion

        #region Methods

        /// <summary>
        ///     Sends a message to the current channel, coming from the originating client
        /// </summary>
        /// <param name="format"></param>
        /// <param name="args"></param>
        /// <returns></returns>
        public bool Message(string format, params object[] args)
        {
            return m_Client.Send("PRIVMSG {0} :{1}", Name, String.Format(format, args));
        }

        #endregion

    }
}
